<template>
  <el-dialog
    title="历史记录"
    v-model="isYn"
    width="50%"
    :before-close="closeHandle"
  >
    <div>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="" label="操作类型">
          <template #default="scope">
            <p v-if="scope.row.operatType === 1">提交备课</p>
            <p v-if="scope.row.operatType === 2">年级审核</p>
            <p v-if="scope.row.operatType === 3">校区审核</p>
            <p v-if="scope.row.operatType === 4">重新提交</p>
          </template>
        </el-table-column>
        <el-table-column prop="creatorName" label="操作人"></el-table-column>
        <el-table-column prop="createTime" label="操作时间"></el-table-column>
        <el-table-column prop="" label="审核结果">
          <template #default="scope">
            <p v-if="scope.row.checkStatus">
              <span
                :class="scope.row.checkStatus === 5 ? 'noPassSpan' : 'passSpan'"
                >·</span
              >
              <span v-show="scope.row.checkStatus === 5">不通过</span>
              <span v-show="scope.row.checkStatus === 4">通过</span>
            </p>
          </template>
        </el-table-column>
        <el-table-column prop="prepareLessonScore" label="评分/点评">
          <template #default="scope">
            <p>
              {{
                scope.row.checkStatus === 5 &&
                scope.row.refuseContents &&
                scope.row.refuseContents.includes("1")
                  ? "教案不合格"
                  : ""
              }}
              {{
                scope.row.checkStatus === 5 &&
                scope.row.refuseContents &&
                scope.row.refuseContents.includes("2")
                  ? "说课不合格"
                  : ""
              }}
              {{
                scope.row.checkStatus === 4 || scope.row.checkStatus === 2
                  ? (scope.row.score > 60 ? scope.row.score : '') 
                  : ""
              }}
            </p>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- <template #footer>
            <span class="dialog-footer">
            <el-button @click="closeHandle('qx')">取 消</el-button>
            <el-button type="primary" @click="closeHandle('sure')">确 定</el-button>
            </span>
        </template> -->
  </el-dialog>
</template>
<script lang="ts">
import { toRefs, defineComponent, reactive } from "vue";
import axios from "axios";
import { AxResponse } from "@/core/axios";
import Moment from "moment";

export default defineComponent({
  setup(props, { emit }) {
    const data = reactive({
      isYn: false,
      tableData: [],
    });
    let open = async (row: any) => {
      data.isYn = true;
      let result = await axios.post<any, AxResponse>(
        "/admin/prepareLesson/queryPrepareLogs",
        { prepareLessonId: row.id },
        { headers: { "Content-Type": "application/x-www-form-urlencoded" } }
      );
      data.tableData = result.json.map((item) => {
        item.createTime = Moment(item.createTime).format("YYYY-MM-DD HH:mm");
        return item;
      });
    };
    let publiSave = () => {
      data.isYn = false;
      data.tableData = [];
    };
    let closeHandle = (tip?: string) => {
      publiSave();
    };
    return { ...toRefs(data), closeHandle, open };
  },
});
</script>

<style scoped lang="scss">
.noPassSpan {
  color: red;
  font-size: 18px;
}
.passSpan {
  color: green;
  font-size: 18px;
}
</style>
